*Set working drive to desired filepath (e.g. C:\Documents\) 
cd "-INSERT DESIRED FILE PATH HERE-"

				*** MAIN MANUSCRIPT ANALYSIS ***
				*DV: Click Rate 
				
*Load data
use Landgrave2020_LSQ0.dta, clear

*Table 3 - Information Acquisition, Reply Rate, and Reply Content by Ethnicity 
	*Column 1 - Resume Click
ttest Click,by(Race)

				
				*DV: Reply Rate & Reply Content

*Load data 
use Landgrave2020_LSQ1.dta, clear 
	
*Table 3 - Information Acquisition, Reply Rate, and Reply Content by Ethnicity 
	*Column 2 - Reply Rate 
ttest DV_Reply,by(Hispanic)
	*Column 3 - Helpfulness 
ttest Help,by(Hispanic)

				
*Table 4 - Reply Content by Ethnicity 
		** Content Analysis **

foreach var of varlist Name GPA Job Volunteer Race Migrant {
ttest `var',by(Hispanic)
} 

*Figure 2 – Determinants of Reply Rate, LPM

eststo Neapolitano: reg DV_Reply i.Hispanic i.nativity i.randomJob i.Violence i.Bernie i.randomHoliday Republican LegHispanic LegFemale //All + Leg Characteristics

coefplot Neapolitano, ///
mlabel format(%9.2f) msize(tiny) mlabposition(12) mlabgap(*2) ///
scheme(plotplainblind) xline(0) ///
ylabel(,nogrid) ///
xlabel(-.15 "-15pp" 0 "0pp" .15 "15pp",nogrid) ///
baselevels drop(_cons) ///
legend(off) ///
headings(0.Hispanic = "{bf:Ethnicity}" ///
0.nativity = "{bf:Citizenship Status}" ///
0.randomJob = "{bf:Dream Job}" ///
0.Violence = "{bf:Reason for Migration}" ///
0.Bernie = "{bf:Volunteer Experience}" ///
0.randomHoliday = "{bf:Holiday Mentioned}" ///
Republican = "{bf:Legislator Characteristics}" ///
)

graph export "Figure2.tif", name("Graph") replace


		
				*** ONLINE APPENDICES ANALYSIS ***

*Appendix Table 1 - Neccesary Sample Size Estimation
	*-White v Hispanic		
** Butler 2014
power twoproportions .5243 .5045
** Gell-Redman 2018
power twoproportions .418 .347
** Mendez & Grose 2018
power twoproportions .504 .443
	*-Citizen v Undocumented 
** Mendez 2013
power twoproportions .311 .252
** Janusz & Lajevardi 2015
power twoproportions .374 .283
	*-Majority vs Minority
**Bartos et al 2016
*Czech Republic, Asian
power twoproportions .633 .475
*Czech Republic, Roma 
power twoproportions .633 .663
*German Labor Market (Turkish)
power twoproportions .81 .75
		
*Appendix Table 2 – Two-Sample Equivalence T-Test, DV: Email Reply Rate	
*NOTE: This requires downloading tostt 
*See https://www.alexisdinno.com/stata/tost.html	
tostt DV_Reply,by(Hispanic) eqvlevel(.1)
tostt DV_Reply,by(Hispanic) eqvlevel(.05)

*Appendix Table 3 – Balance Table	
ttest Republican,by(Hispanic) 
ttest LegWhite,by(Hispanic)
ttest LegHispanic,by(Hispanic)
ttest LegFemale,by(Hispanic) 
ttest squire_index,by(Hispanic) 

*Appendix Table 4 – Email Reply Rates by Citizenship Status and State Undocumented Student Policy
*All Legislators 
ttest DV_Reply,by(CitizenVUndoc)
*Undocumented Ban 
ttest DV_Reply if FriendlyState == 0,by(CitizenVUndoc)
*Neutral
ttest DV_Reply if FriendlyState == 1,by(CitizenVUndoc)
*In-state Tuition
ttest DV_Reply if FriendlyState == 2,by(CitizenVUndoc) 

*Appendix Table 5 – Email Reply Rates by Citizenship Status and Ethnicity
*All 
ttest DV_Reply,by(Hispanic)	
*Citizen
ttest DV_Reply if nativity == 0,by(Hispanic)
*Permanent Resident
ttest DV_Reply if nativity == 1,by(Hispanic)
*DACAmented
ttest DV_Reply if nativity == 2,by(Hispanic)
*Undocumented
ttest DV_Reply if nativity == 3,by(Hispanic)

*Appendix Table 6 – Email Reply Rates by Citizenship Status and Party ID
*All Legislators
ttest DV_Reply,by(CitizenVUndoc)
*Democratic Legislators
ttest DV_Reply if Republican == 0,by(CitizenVUndoc)
*Republican Legislators
ttest DV_Reply if Republican == 1,by(CitizenVUndoc)
*p-value .0324

*Appendix Table 7 – Email Reply Rates by DACA Status and Party ID
*All Legislators
ttest DV_Reply,by(DACAStatus)
*Democrat Legislators
ttest DV_Reply if Republican == 0,by(DACAStatus)
*Republican Legislators
ttest DV_Reply if Republican == 1,by(DACAStatus)

*Appendix Table 8 – Citizen vs. Undocumented (without DACA), LPM
*Column 1
reg DV_Reply citizen4 NeutralPolicy FriendlyPolicy ///
if citizen2 == 0 & citizen3 == 0
outreg2 using AppendixTable8.xls, replace ///
title("Reply Rate; Citizen vs. Undocumented (without DACA)") label 
*Column 2
reg DV_Reply citizen4 NeutralPolicy FriendlyPolicy ///
TrumpShare HispanicShare Professional if citizen2 == 0 & citizen3 == 0
outreg2 using AppendixTable8.xls.xls, append label 
*Column 3
reg DV_Reply citizen4 NeutralPolicy FriendlyPolicy ///
UndocNeutralPolicy UndocFriendlyPolicy ///
TrumpShare HispanicShare Professional if citizen2 == 0 & citizen3 == 0
outreg2 using AppendixTable8.xls.xls, append label 

*Appendix Table 9 – Sentiment Analysis by Citizenship Status and State Undocumented Student Policy
*All Legislators
ttest Sentiment,by(CitizenVUndoc)
*Undocumented Ban
ttest Sentiment if FriendlyState == 0,by(CitizenVUndoc)
*Neutral
ttest Sentiment if FriendlyState == 1,by(CitizenVUndoc)
*In-state Tuition
ttest Sentiment if FriendlyState == 2,by(CitizenVUndoc) 
